//package com.xdtech.init;
//
//import java.io.BufferedReader;
//import java.io.File;
//import java.io.FileInputStream;
//import java.io.FileOutputStream;
//import java.io.InputStreamReader;
//import java.io.OutputStreamWriter;
//import java.util.ArrayList;
//import java.util.List;
//
//import org.apache.commons.logging.Log;
//import org.apache.commons.logging.LogFactory;
//import org.springframework.context.ApplicationContext;
//import org.springframework.context.support.ClassPathXmlApplicationContext;
//import org.springframework.jdbc.core.JdbcTemplate;
//
//import com.xdtech.common.service.impl.BaseService;
//import com.xdtech.common.utils.ApplicationContextUtil;
//import com.xdtech.common.utils.EncryptUtil;
//import com.xdtech.common.utils.encrypt.DESCoder;
//import com.xdtech.core.init.SysInitOperation;
//import com.xdtech.core.model.BaseModel;
//import com.xdtech.forum.model.Article;
//import com.xdtech.forum.model.Category;
//import com.xdtech.forum.model.CommentInfo;
//import com.xdtech.forum.model.LinkTag;
//import com.xdtech.forum.model.Member;
//import com.xdtech.forum.service.ArticleService;
//import com.xdtech.forum.service.CategoryService;
//import com.xdtech.forum.service.CommentInfoService;
//import com.xdtech.forum.service.LinkTagService;
//import com.xdtech.forum.service.MemberService;
//import com.xdtech.report.model.Config;
//import com.xdtech.report.service.ConfigService;
//import com.xdtech.sys.model.CodeValue;
//import com.xdtech.sys.model.DictionaryCode;
//import com.xdtech.sys.model.MenuFunction;
//import com.xdtech.sys.model.Operation;
//import com.xdtech.sys.model.Role;
//import com.xdtech.sys.model.User;
//import com.xdtech.sys.model.UserGroup;
//import com.xdtech.sys.service.CodeValueService;
//import com.xdtech.sys.service.DictionaryCodeService;
//import com.xdtech.sys.service.MenuFunctionService;
//import com.xdtech.sys.service.OperationService;
//import com.xdtech.sys.service.RoleService;
//import com.xdtech.sys.service.UserGroupService;
//import com.xdtech.sys.service.UserService;
//
//
//
//public class InitData implements SysInitOperation {
//	
//	static ApplicationContext context = null;
//	static UserService userService = null;
//	static RoleService roleService = null;
//	static UserGroupService userGroupService = null;
//	static MenuFunctionService menuFunctionService = null;
//	static OperationService operationService = null;
//	static ConfigService configService = null;
//
//	static void loadSpringContext() {
//		context = new ClassPathXmlApplicationContext("applicationContext.xml");
//	}
//	/**
//	 * 代码初始化数据
//	 */
//	public static void main(String[] args) {
//		loadSpringContext();
//		initStarting();
//	}
//	/**
//	 * 应用容器初始化数据
//	 * 
//	 * @author max.zheng
//	 * @create 2015-3-10下午10:34:05
//	 * @modified by
//	 */
//	public static void initWebApp() {
//		context = ApplicationContextUtil.getContext();
//		initStarting();
//	}
//	
//	/**
//	 * 
//	 * @author max.zheng
//	 * @create 2015-3-10下午10:33:34
//	 * @modified by
//	 */
//	private static void initStarting() {
//		userService = context.getBean(UserService.class);
//		roleService = context.getBean(RoleService.class);
//		userGroupService = context.getBean(UserGroupService.class);
//		menuFunctionService = context.getBean(MenuFunctionService.class);
//		operationService = context.getBean(OperationService.class);
//		configService = context.getBean(ConfigService.class);
//		//清空库数据
//		dropDatabase();
//		//初始化系统管理模块
//		initSys();
//		//初始化数据字典
//		initDictionary();
//		//初始化报表demo
//		initReportDemo();
//		//初始化论坛demo
//		initForumDemo();
//	}
//	
//	
//	/**
//	 * 初始化论坛demo
//	 * @author <a href="max.zheng@zkteco.com">郑志雄</>
//	 * @since 2015-3-6 下午1:43:34
//	 */
//	private static void initForumDemo()
//	{
//		MemberService memberService = context.getBean(MemberService.class);
//		Member member = new Member();
//		member.setName("max");
//		member.setNickName("max");
//		member.setEmail("123456@qq.com");
//		member.setPassword(DESCoder.encrypt("123456"));
//		member.setSex("M");
//		memberService.save(member);
//		CategoryService categoryService = context.getBean(CategoryService.class);
//		List<Category> entities = new ArrayList<Category>();
//		entities.add(new Category("1","问题反馈","fa-file-text"));
//		entities.add(new Category("2","平台交流","fa-bell-o"));
//		categoryService.saveAll(entities);
//		
//		LinkTagService linkTagService = context.getBean(LinkTagService.class);
//		List<LinkTag> linkTags = new ArrayList<LinkTag>();
//		//关键字创建
//		linkTags.add(new LinkTag("java", "1", "", ""));
//		linkTags.add(new LinkTag("jmax", "1", "", ""));
//		linkTags.add(new LinkTag("前端", "1", "", ""));
//		linkTags.add(new LinkTag("极速开发平台", "1", "", ""));
//		//友情链接地址
//		linkTags.add(new LinkTag("百度", "2", "http://www.baidu.com", ""));
//		linkTags.add(new LinkTag("个人博客", "2", "http://java4ever.iteye.com", ""));
//		//联系
//		linkTags.add(new LinkTag("QQ", "3", "", "webpages/forum/portal/images/max.jpg"));
//		//广告
//		linkTags.add(new LinkTag("广告", "4", "http://www.baidu.com", "webpages/forum/portal/images/max.jpg"));
//		linkTagService.saveAll(linkTags);
//		
//		ArticleService articleService = context.getBean(ArticleService.class);
//		Article article = new Article("JMax快速开发平台","JMax由java开发，基于spring+hibernate+easyui整合的一套综合从前端到后端一体化框架,UI自定义封装，方便用户快捷使用，sql模版自定义，灵活配置，代码自动速成，一键开发，图表配置，立即预览",new Category(2L));
//		article.setIsHot("true");
//		article.setIcon("webpages/forum/portal/images/jmax-home.png");
//		article.setMember(new Member(1L));
//		articleService.save(article);
//		
//		article = new Article("报表图表","根据配置的sql和xml，自动完成报表导出和图表显示功能。",new Category(1L));
//		article.setIsHot("true");
//		article.setMember(new Member(1L));
//		articleService.save(article);
//		
//		CommentInfoService commentInfoService = context.getBean(CommentInfoService.class);
//		CommentInfo commentInfo = new CommentInfo();
//		commentInfo.setContent("好东西，赞一个，支持开源");
//		commentInfo.setMember(member);
//		commentInfo.setArticle(article);
//		commentInfoService.save(commentInfo);
//	}
//
//	/**
//	 * 
//	 * @author <a href="max.zheng@zkteco.com">郑志雄</>
//	 * @since 2015-3-3 上午10:03:54
//	 */
//	private static void dropDatabase()
//	{
//		JdbcTemplate jdbcTemplate = context.getBean(JdbcTemplate.class);
////		jdbcTemplate.execute("truncate database jmax_sys");
//		
//	}
//
//	/**
//	 * 初始化reportDemo
//	 * @author <a href="max.zheng@zkteco.com">郑志雄</>
//	 * @since 2015-2-16 上午9:40:35
//	 */
//	private static void initReportDemo()
//	{
//		Config configZhuZhuan = new Config("系统日志柱状图","<?xml version=\"1.0\" encoding=\"UTF-8\"?><report><columns><column field=\"OPERATOR\" title=\"操作人\" type=\"xAxis\"></column><column field=\"count\" title=\"日志量\" width=\"150\"></column><column field=\"ces\" title=\"测试\"></column></columns><datagrid><searchs><showsearch><item name=\"operator\" label=\"操作人\" type=\"textbox\"></item></showsearch><hidesearch></hidesearch></searchs></datagrid><highcharts><chart><!-- 图表类型配置 --><type>column</type></chart><exporting><enabled>true</enabled></exporting><credits><enabled>true</enabled><text>JMax平台</text><href></href></credits><plotOptions><series><animation>true</animation></series></plotOptions><yAxis><title><text>数量</text></title></yAxis></highcharts></report>","SELECT OPERATOR,COUNT(*) as count,10 as ces FROM sys_log GROUP BY OPERATOR <#if operator??>having OPERATOR='${operator}' </#if>");
//		Config configPie = new Config("系统日志饼图","<?xml version=\"1.0\" encoding=\"UTF-8\"?><report><columns><column field=\"OPERATOR\" title=\"操作人\" type=\"xAxis\"></column><column field=\"count\" title=\"日志量\" width=\"150\"></column></columns><datagrid><searchs><showsearch></showsearch><hidesearch></hidesearch></searchs></datagrid><highcharts><chart><!-- 图表类型配置 --><type>pie</type></chart><exporting><enabled>true</enabled></exporting><credits><enabled>false</enabled><text>JMax</text><href></href></credits><plotOptions><pie><allowPointSelect>true</allowPointSelect><cursor>pointer</cursor>	<dataLabels><enabled>true</enabled><color>#000000</color>	<connectorColor>#000000</connectorColor><format>{point.name}: {point.percentage:.1f} %</format>	</dataLabels></pie></plotOptions><yAxis><title><text>数量</text></title></yAxis></highcharts></report>","SELECT OPERATOR,COUNT(*) as count FROM sys_log GROUP BY OPERATOR");
//		Config configLine = new Config("系统日志折线图","<?xml version=\"1.0\" encoding=\"UTF-8\"?><report><columns><column field=\"OPERATOR\" title=\"操作人\" type=\"xAxis\"></column><column field=\"count\" title=\"日志量\" width=\"150\"></column><column field=\"ces\" title=\"测试\"></column></columns><datagrid><searchs><showsearch></showsearch><hidesearch></hidesearch></searchs></datagrid><highcharts><chart><!-- 图表类型配置 --><type>line</type></chart><exporting><enabled>true</enabled></exporting><credits><enabled>true</enabled><text>JMax平台</text><href></href></credits><plotOptions><series><animation>true</animation></series></plotOptions><yAxis><title><text>数量</text></title></yAxis></highcharts></report>","SELECT OPERATOR,COUNT(*) as count,10 as ces FROM sys_log GROUP BY OPERATOR");
//		configService.save(configZhuZhuan);
//		configService.save(configPie);
//		configService.save(configLine);
//		Config configBrowerPie = new Config("访问浏览器占比", "<?xml version=\"1.0\" encoding=\"UTF-8\"?><report><columns><column field=\"BROWSER_TYPE\" title=\"浏览器类型\" type=\"xAxis\"></column><column field=\"count\" title=\"访问量\" width=\"150\"></column></columns><datagrid><searchs><showsearch></showsearch><hidesearch></hidesearch></searchs></datagrid><highcharts><chart><!-- 图表类型配置 --><type>pie</type></chart><exporting><enabled>true</enabled></exporting><credits><enabled>false</enabled><text>JMax</text><href></href></credits><plotOptions><pie><allowPointSelect>true</allowPointSelect><cursor>pointer</cursor>	<dataLabels><enabled>true</enabled><color>#000000</color>	<connectorColor>#000000</connectorColor><format>{point.name}: {point.percentage:.1f} %</format>	</dataLabels></pie></plotOptions><yAxis><title><text>数量</text></title></yAxis></highcharts></report>","SELECT BROWSER_TYPE,COUNT(*) AS count FROM jmax_page_view GROUP BY BROWSER_TYPE");
//		configService.save(configBrowerPie);
//		Config dayVisit = new Config("日访问趋势图","<?xml version=\"1.0\" encoding=\"UTF-8\"?><report><columns><column field=\"days\" title=\"日\" type=\"xAxis\"></column><column field=\"count\" title=\"访问量\" width=\"150\"></column></columns><datagrid><searchs><showsearch></showsearch><hidesearch></hidesearch></searchs></datagrid><highcharts><chart><!-- 图表类型配置 --><type>line</type></chart><exporting><enabled>true</enabled></exporting><credits><enabled>true</enabled><text>JMax平台</text><href></href></credits><plotOptions><series><animation>true</animation></series></plotOptions><yAxis><title><text>数量</text></title></yAxis></highcharts></report>","SELECT DATE_FORMAT(create_time,'%Y%m%d') days,COUNT(id) count FROM jmax_page_view GROUP BY days");
//		Config weekVisit = new Config("周访问趋势图","<?xml version=\"1.0\" encoding=\"UTF-8\"?><report><columns><column field=\"weeks\" title=\"周\" type=\"xAxis\"></column><column field=\"count\" title=\"访问量\" width=\"150\"></column></columns><datagrid><searchs><showsearch></showsearch><hidesearch></hidesearch></searchs></datagrid><highcharts><chart><!-- 图表类型配置 --><type>line</type></chart><exporting><enabled>true</enabled></exporting><credits><enabled>true</enabled><text>JMax平台</text><href></href></credits><plotOptions><series><animation>true</animation></series></plotOptions><yAxis><title><text>数量</text></title></yAxis></highcharts></report>","SELECT DATE_FORMAT(create_time,'%Y%u') weeks,COUNT(id) count FROM jmax_page_view GROUP BY weeks");
//		Config monthVisit = new Config("月访问趋势图","<?xml version=\"1.0\" encoding=\"UTF-8\"?><report><columns><column field=\"months\" title=\"月\" type=\"xAxis\"></column><column field=\"count\" title=\"访问量\" width=\"150\"></column></columns><datagrid><searchs><showsearch></showsearch><hidesearch></hidesearch></searchs></datagrid><highcharts><chart><!-- 图表类型配置 --><type>line</type></chart><exporting><enabled>true</enabled></exporting><credits><enabled>true</enabled><text>JMax平台</text><href></href></credits><plotOptions><series><animation>true</animation></series></plotOptions><yAxis><title><text>数量</text></title></yAxis></highcharts></report>","SELECT DATE_FORMAT(create_time,'%Y%m') months,COUNT(id) count FROM jmax_page_view GROUP BY months");
//		configService.save(dayVisit);
//		configService.save(weekVisit);
//		configService.save(monthVisit);
//	}
//
//	/**
//	 * 
//	 * @author max.zheng
//	 * @create 2015-2-15下午8:26:02
//	 * @modified by
//	 */
//	private static void initDictionary() {
//		DictionaryCodeService dictionaryCodeService = context.getBean(DictionaryCodeService.class);
//		CodeValueService codeValueService = context.getBean(CodeValueService.class);
//		List<DictionaryCode> dictionaryCodes = new ArrayList<DictionaryCode>();
// 		DictionaryCode dictionaryCode = new DictionaryCode("SEX","性别");
//		dictionaryCodeService.save(dictionaryCode);
//		codeValueService.save(new CodeValue("M","男",1,dictionaryCode));
//		codeValueService.save(new CodeValue("F","女",2,dictionaryCode));
//		
//		dictionaryCode = new DictionaryCode("YON","是否");
//		dictionaryCodeService.save(dictionaryCode);
//		codeValueService.save(new CodeValue("true","是",1,dictionaryCode));
//		codeValueService.save(new CodeValue("false","否",2,dictionaryCode));
//		
//		dictionaryCode = new DictionaryCode("FIELD_TYPE","属性类型");
//		dictionaryCodeService.save(dictionaryCode);
//		codeValueService.save(new CodeValue("Integer","整型",1,dictionaryCode));
//		codeValueService.save(new CodeValue("Long","长整型",2,dictionaryCode));
//		codeValueService.save(new CodeValue("String","字符型",3,dictionaryCode));
//		codeValueService.save(new CodeValue("Date","日期型",4,dictionaryCode));
//		codeValueService.save(new CodeValue("Timestamp","时间型",5,dictionaryCode));
//
//		dictionaryCode = new DictionaryCode("EXPORT_REPORT_TYPE","导出报表类型");
//		dictionaryCodeService.save(dictionaryCode);
//		codeValueService.save(new CodeValue("EXCEL","EXCEL",1,dictionaryCode));
//		codeValueService.save(new CodeValue("PDF","PDF",2,dictionaryCode));
//		codeValueService.save(new CodeValue("CVS","CVS",3,dictionaryCode));
//		codeValueService.save(new CodeValue("TXT","TXT",4,dictionaryCode));
//		codeValueService.save(new CodeValue("HTML","HTML",5,dictionaryCode));
//		
//		dictionaryCode = new DictionaryCode("USER_STATUS","用户状态");
//		dictionaryCodeService.save(dictionaryCode);
//		codeValueService.save(new CodeValue("1","启用",1,dictionaryCode));
//		codeValueService.save(new CodeValue("0","禁用",2,dictionaryCode));
//		
//		dictionaryCode = new DictionaryCode("FORUM_LINK_TAG_TYPE","快捷链接类型");
//		dictionaryCodeService.save(dictionaryCode);
//		codeValueService.save(new CodeValue("1","关键字",1,dictionaryCode));
//		codeValueService.save(new CodeValue("2","友情链接",2,dictionaryCode));
//		codeValueService.save(new CodeValue("3","联系",3,dictionaryCode));
//		codeValueService.save(new CodeValue("4","广告",4,dictionaryCode));
//		
//		dictionaryCode = new DictionaryCode("RULE_TYPE","规则类型符");
//		dictionaryCodeService.save(dictionaryCode);
//		codeValueService.save(new CodeValue("in","包括在...",1,dictionaryCode));
//		codeValueService.save(new CodeValue("eq","等于",2,dictionaryCode));
//	}
//
//	private static void initSys() {
//		User root = new User();
//		root.setLoginName("root");
//		root.setName("超级用户");
//		root.setSex("F");
//		root.setStatus("1");
//		root.setPassword(EncryptUtil.encodePassword("root"));
//		userService.save(root);
//		
//		User admin = new User();
//		admin.setLoginName("admin");
//		admin.setName("管理员");
//		admin.setSex("F");
//		admin.setStatus("1");
//		admin.setPassword(EncryptUtil.encodePassword("admin"));
//		userService.save(admin);
//		
//		User normal = new User();
//		normal.setLoginName("normal");
//		normal.setName("普通用户");
//		normal.setSex("F");
//		normal.setStatus("1");
//		normal.setPassword(EncryptUtil.encodePassword("normal"));
//		userService.save(normal);
//		
//		User test = new User();
//		test.setLoginName("test");
//		test.setName("测试用户");
//		test.setSex("F");
//		test.setStatus("1");
//		test.setPassword(EncryptUtil.encodePassword("test"));
//		userService.save(test);
//		
//		Role superManager = new Role();
//		superManager.setEnable(true);
//		superManager.setCode("super-administrator");
//		superManager.setSuperuser(true);
//		superManager.setDescription("超级管理员角色描述");
//		superManager.setName("超级管理员角色");
//		roleService.save(superManager);
//		root.getRoles().add(superManager);
//		userService.save(root);
//		
//		Role adminManager = new Role();
//		adminManager.setEnable(true);
//		adminManager.setCode("administrator");
//		adminManager.setName("管理员角色");
//		adminManager.setDescription("管理员角色描述");
//		roleService.save(adminManager);
//		admin.getRoles().add(superManager);
//		userService.save(admin);
//		
//		Role normalManager = new Role();
//		normalManager.setEnable(true);
//		normalManager.setCode("normal-admin");
//		normalManager.setName("普通管理员角色");
//		normalManager.setDescription("普通管理员角色描述");
//		roleService.save(normalManager);
//		normal.getRoles().add(normalManager);
//		userService.save(normal);
//		
//		Role testRole = new Role();
//		testRole.setEnable(true);
//		testRole.setCode("test");
//		testRole.setName("测试角色");
//		testRole.setDescription("测试角色描述");
//		roleService.save(testRole);
//		
//		UserGroup rootGroup = new UserGroup();
//		rootGroup.setName("JMax平台");
//		rootGroup.setParent(null);
//		userGroupService.save(rootGroup);
//		
//		UserGroup group1 = new UserGroup();
//		group1.setName("XX公司");
//		group1.setParent(rootGroup);
//		group1.getUsers().add(test);
//		userGroupService.save(group1);
//		
//		
//		UserGroup group11 = new UserGroup();
//		group11.setName("XX部门");
//		group11.setParent(group1);
//		group11.getUsers().add(test);
//		userGroupService.save(group11);
//		
//		
//		MenuFunction m1 = new MenuFunction();
//		m1.setIconName("icon-system");
//		m1.setNameCN("系统管理");
//		m1.setOperationCode("system-manage");
//		m1.setPageUrl(null);
////		m1.getRoles().add(superManager);
//		menuFunctionService.save(m1);
//		
//		
//		
//		MenuFunction m11 = new MenuFunction();
//		m11.setIconName("icon-user");
//		m11.setNameCN("用户管理");
//		m11.setOperationCode("user-manage");
//		m11.setPageUrl("user.do?user");
//		m11.setParent(m1);
////		m11.getRoles().add(superManager);
//		menuFunctionService.save(m11);
//		
//		createButtonOperations("新增","sys:user:add",m11);
//		createButtonOperations("删除","sys:user:delete",m11);
//		createButtonOperations("编辑","sys:user:edit",m11);
//		createButtonOperations("清空","sys:user:clear",m11);
//		createButtonOperations("禁用","sys:user:disable",m11);
//		createButtonOperations("启用","sys:user:enable",m11);
//		createButtonOperations("刷新","sys:user:refresh",m11);
//		createButtonOperations("用户角色","sys:user:linkRole",m11);
//		
//		MenuFunction m12 = new MenuFunction();
//		m12.setIconName("icon-role");
//		m12.setNameCN("角色管理");
//		m12.setOperationCode("role-manage");
//		m12.setPageUrl("role.do?role");
//		m12.setParent(m1);
////		m12.getRoles().add(superManager);
//		menuFunctionService.save(m12);
//		
//		createButtonOperations("新增","sys:role:add",m12);
//		createButtonOperations("删除","sys:role:delete",m12);
//		createButtonOperations("编辑","sys:role:edit",m12);
//		createButtonOperations("刷新","sys:role:refresh",m12);
//		createButtonOperations("授权","sys:role:auth",m12);
//
//		MenuFunction m13 = new MenuFunction();
//		m13.setIconName("icon-usergroup");
//		m13.setNameCN("用户组管理");
//		m13.setOperationCode("usergroup-manage");
//		m13.setPageUrl("group.do?group");
//		m13.setParent(m1);
////		m13.getRoles().add(superManager);
//		menuFunctionService.save(m13);
//		
//		createButtonOperations("新增","sys:usergroup:add",m13);
//		createButtonOperations("删除","sys:usergroup:delete",m13);
//		createButtonOperations("编辑","sys:usergroup:save",m13);
//		
//		MenuFunction m14 = new MenuFunction();
//		m14.setIconName("icon-menu");
//		m14.setNameCN("菜单管理");
//		m14.setOperationCode("menu-manage");
//		m14.setPageUrl("menuFunction.do?sysFunction");
//		m14.setParent(m1);
////		m14.getRoles().add(superManager);
//		menuFunctionService.save(m14);
//		
//		createButtonOperations("新增菜单","sys:menu:add",m14);
//		createButtonOperations("删除菜单","sys:menu:delete",m14);
//		createButtonOperations("保存菜单","sys:menu:save",m14);
//		createButtonOperations("新增按钮","sys:operation:add",m14);
//		createButtonOperations("删除按钮","sys:operation:delete",m14);
//		createButtonOperations("保存按钮","sys:operation:save",m14);
//		
//		MenuFunction m15 = new MenuFunction();
//		m15.setIconName("icon-dictionary");
//		m15.setNameCN("数据字典");
//		m15.setOperationCode("dictionary-manage");
//		m15.setPageUrl("dictionaryCode.do?dictionary");
//		m15.setParent(m1);
////		m15.getRoles().add(superManager);
//		menuFunctionService.save(m15);
//		
//		createButtonOperations("新增字典","sys:dictionary:add",m15);
//		createButtonOperations("编辑字典","sys:dictionary:edit",m15);
//		createButtonOperations("删除字典","sys:dictionary:delete",m15);
//		createButtonOperations("刷新字典","sys:dictionary:refresh",m15);
//		
//		MenuFunction m16 = new MenuFunction();
//		m16.setIconName("icon-session");
//		m16.setNameCN("会话监控");
//		m16.setOperationCode("session-monitor");
//		m16.setPageUrl("session.do?session");
//		m16.setParent(m1);
////		m16.getRoles().add(superManager);
//		menuFunctionService.save(m16);
//		
//		createButtonOperations("强制退出","sys:session:delete",m16);
//		createButtonOperations("刷新","sys:session:refresh",m16);
//		
//		MenuFunction m17 = new MenuFunction();
//		m17.setIconName("icon-log");
//		m17.setNameCN("日志信息");
//		m17.setOperationCode("log-manage");
//		m17.setPageUrl("log.do?log");
//		m17.setParent(m1);
//		menuFunctionService.save(m17);
//		createButtonOperations("刷新日志","sys:log:refresh",m17);
//		
//		//数据权限
//		MenuFunction m18 = new MenuFunction();
//		m18.setIconName("icon-save");
//		m18.setNameCN("数据权限");
//		m18.setOperationCode("data-permission");
//		m18.setPageUrl("null");
//		m18.setParent(m1);
//		menuFunctionService.save(m18);
//		//资源定义
//		MenuFunction m181 = new MenuFunction();
//		m181.setIconName("icon-save");
//		m181.setNameCN("资源定义");
//		m181.setOperationCode("resource-definition");
//		m181.setPageUrl("resource.do?resource");
//		m181.setParent(m18);
//		menuFunctionService.save(m181);
//		
//		
////		createButtonOperations("刷新资源","sys:resource:refresh",m18);
//		
//		MenuFunction m2 = new MenuFunction();
//		m2.setIconName("icon-chart-manage");
//		m2.setNameCN("报表管理");
//		m2.setOperationCode("report-manage");
//		m2.setPageUrl(null);
////		m2.getRoles().add(superManager);
//		menuFunctionService.save(m2);
//		
//		MenuFunction m21 = new MenuFunction();
//		m21.setIconName("icon-chart-config");
//		m21.setNameCN("报表配置");
//		m21.setOperationCode("reportconfig-manage");
//		m21.setPageUrl("config.do?config");
//		m21.setParent(m2);
////		m21.getRoles().add(superManager);
//		menuFunctionService.save(m21);
//		createButtonOperations("新增报表","sys:report:add",m21);
//		createButtonOperations("编辑报表","sys:report:edit",m21);
//		createButtonOperations("删除报表","sys:report:delete",m21);
//		createButtonOperations("刷新报表","sys:report:refresh",m21);
//		
//		MenuFunction m22 = new MenuFunction();
//		m22.setIconName("icon-chart-read");
//		m22.setNameCN("报表预览");
//		m22.setOperationCode("reportread-manage");
//		m22.setPageUrl("readReport.do?read");
//		m22.setParent(m2);
////		m22.getRoles().add(superManager);
//		menuFunctionService.save(m22);
////		
//		MenuFunction m3 = new MenuFunction();
//		m3.setIconName("icon-quick-coder");
//		m3.setNameCN("敏捷开发");
//		m3.setOperationCode("quick-coder");
//		m3.setPageUrl(null);
////		m3.getRoles().add(superManager);
//		menuFunctionService.save(m3);
//		
//		MenuFunction m31 = new MenuFunction();
//		m31.setIconName("icon-coder-config");
//		m31.setNameCN("代码速成");
//		m31.setOperationCode("codecreater-manage");
//		m31.setPageUrl("codeCreater.do?codeCreater");
////		m31.getRoles().add(superManager);
//		m31.setParent(m3);
//		menuFunctionService.save(m31);
//		
//		createButtonOperations("新增属性","sys:coderFiled:add",m31);
//		createButtonOperations("删除属性","sys:coderFiled:delete",m31);
//		
//		MenuFunction m4 = new MenuFunction();
//		m4.setIconName("icon-project");
//		m4.setNameCN("案例演示");
//		m4.setOperationCode("codecreater-manage");
//		menuFunctionService.save(m4);
//		
//		MenuFunction m41 = new MenuFunction();
//		m41.setIconName("icon-score");
//		m41.setNameCN("商城管理");
//		m41.setOperationCode("shop-manage");
//		m41.setParent(m4);
//		menuFunctionService.save(m41);
//		
//		MenuFunction m42 = new MenuFunction();
//		m42.setIconName("icon-forum");
//		m42.setNameCN("论坛管理");
//		m42.setOperationCode("forum-manage");
//		m42.setParent(m4);
//		menuFunctionService.save(m42);
//		
//		MenuFunction m421 = new MenuFunction();
//		m421.setIconName("icon-category");
//		m421.setNameCN("帖子类别");
//		m421.setOperationCode("category-manage");
//		m421.setPageUrl("category.do?category");
//		m421.setParent(m42);
//		menuFunctionService.save(m421);
//		
//		MenuFunction m422 = new MenuFunction();
//		m422.setIconName("icon-article");
//		m422.setNameCN("帖子管理");
//		m422.setOperationCode("article-manage");
//		m422.setPageUrl("article.do?article");
//		m422.setParent(m42);
//		menuFunctionService.save(m422);
//		MenuFunction m423 = new MenuFunction();
//		m423.setIconName("icon-member");
//		m423.setNameCN("会员管理");
//		m423.setOperationCode("member-manage");
//		m423.setPageUrl("member.do?member");
//		m423.setParent(m42);
//		menuFunctionService.save(m423);
//		
//		MenuFunction m424 = new MenuFunction();
//		m424.setIconName("icon-save");
//		m424.setNameCN("快捷标签");
//		m424.setOperationCode("quick-tag");
//		m424.setPageUrl("linkTag.do?linkTag");
//		m424.setParent(m42);
//		menuFunctionService.save(m424);
//		
//		MenuFunction m425 = new MenuFunction();
//		m425.setIconName("icon-comment-info");
//		m425.setNameCN("评论管理");
//		m425.setOperationCode("comment-manage");
//		m425.setPageUrl("commentInfo.do?commentInfo");
//		m425.setParent(m42);
//		menuFunctionService.save(m425);
//		
//		MenuFunction m426 = new MenuFunction();
//		m426.setIconName("icon-portal");
//		m426.setNameCN("论坛门户");
//		m426.setOperationCode("forum-look");
//		m426.setPageUrl("portal.action?index");
//		m426.setIframe(true);
//		m426.setParent(m42);
//		menuFunctionService.save(m426);
//		
//		MenuFunction m43 = new MenuFunction();
//		m43.setIconName("icon-save");
//		m43.setNameCN("运输管理");
//		m43.setOperationCode("tran-manage");
//		m43.setParent(m4);
//		menuFunctionService.save(m43);
//		
//		MenuFunction m431 = new MenuFunction();
//		m431.setIconName("icon-save");
//		m431.setNameCN("订单管理");
//		m431.setOperationCode("tran-order-manage");
//		m431.setPageUrl("tranOrder.do?tranOrder");
//		m431.setParent(m43);
//		menuFunctionService.save(m431);
//		
//		MenuFunction m432 = new MenuFunction();
//		m432.setIconName("icon-save");
//		m432.setNameCN("司机管理");
//		m432.setOperationCode("tran-driver-manage");
//		m432.setPageUrl("tranDriver.do?tranDriver");
//		m432.setParent(m43);
//		menuFunctionService.save(m432);
//	}
//
//	/**
//	 * 
//	 * @author max.zheng
//	 * @create 2015-2-15下午10:29:11
//	 * @modified by
//	 * @param m11
//	 */
//	private static void createButtonOperations(String nameCN, String operationCode,
//			MenuFunction menuFunction) {
//		Operation operation = new Operation(nameCN, operationCode, menuFunction);
//		operationService.save(operation);
//		
//	}
//	
//	Log log = LogFactory.getLog(InitData.class);
//	/**
//	 * @description
//	 * @author max.zheng
//	 * @create 2015-3-10下午10:36:18
//	 * @modified by
//	 * @param baseService
//	 */
//	@Override
//	public void initingToDb(BaseService<BaseModel> baseService) {
//		log.info("数据库初始化数据开始......");
//		initWebApp();
//		// 更改配置文件内容,下次不初始化
//		log.info("数据库初始化标记更改........");
//		changeAlreadyFlag("system.isInitDataToDb","false");
//		log.info("数据库初始化结束......");
//	}
//	/**
//	 * 
//	 * @author max.zheng
//	 * @throws Exception 
//	 * @throws  
//	 * @create 2014-12-28下午10:01:58
//	 * @modified by
//	 */
//	private void changeAlreadyFlag(String key,String value) {
//		try {
//			File file = new File(this.getClass().getResource("/").getPath()+"application.properties");
//			BufferedReader bufferedReader = new BufferedReader(
//					(new InputStreamReader(new FileInputStream(file), "utf-8")));
//			StringBuffer stringBuffer = new StringBuffer();
//			String line = null;
//			boolean state = false;
//			while ((line = bufferedReader.readLine()) != null) {
//				if (line.contains(key)) {
//					stringBuffer.append(key + "=" + value);
//					state = true;
//				} else {
//					stringBuffer.append(line);
//				}
//				stringBuffer.append("\r\n");
//			}
//			OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(
//					file), "utf-8");
//			osw.write(stringBuffer.toString());
//			osw.close();
//		}catch (Exception e) {
//			log.error("关闭设备初始化数据库参数异常",e);
//		}
//		
//	}
//	/**
//	 * @description
//	 * @author max.zheng
//	 * @create 2015-3-10下午10:36:18
//	 * @modified by
//	 * @param baseService
//	 */
//	@Override
//	public void initingToCache(BaseService<BaseModel> baseService) {
//		
//	}
//	/* (非 Javadoc)
//	 * getInitOrder
//	 * <p>对override方法的补充说明，若不需要则删除此行</p>
//	 * 
//	 * @return
//	 * @see com.xdtech.core.init.SysInitOperation#getInitOrder()
//	 */
//	@Override
//	public int getInitOrder()
//	{
//		// TODO Auto-generated method stub
//		return 0;
//	}
//
//}
